from time import sleep
from page_locators.login_page_locator import LoginPageLocators as LPL
from common.base_page import BasePage
from test_datas.login_datas import *
from test_datas.pic_data import *


class ClassDescription(BasePage):

    def __init__(self, driver):
        super().__init__(driver)

    def digital_class_management(self, username, password):
        self.input(LPL.username_loc, username, '用户名输入失败截图')
        self.input(LPL.password_loc, password, '密码输入失败截图')
        code = self.get_code(LPL.captcha_img, 'src', '验证码图片定位')
        self.input(LPL.captcha, code, '验证码输入')
        sleep(1)
        self.click(LPL.loginsbt, '登录按钮点击失败截图')
        sleep(1)
        self.switch_window()
        sleep(1)
        self.click(LPL.digital_class_management_loc, '数字化班级管理按钮定位错误截图')

    def click_class_description(self):
        self.click(LPL.click_class_description, "班级简介定位点击")

    def upload_pictures1(self):
        sleep(1)
        self.upload_file(LPL.upload_pictures, getFile_png, "上传头像定位失败截图")
        self.back()
        sleep(1)
        self.forward()

    def upload_pictures2(self):
        sleep(1)
        self.upload_file(LPL.upload_pictures, webp_path, "上传头像定位失败截图")

    def upload_pictures3(self):
        sleep(1)
        self.upload_file(LPL.upload_pictures, big_path, "上传头像定位失败截图")

    def upload_pictures4(self):
        sleep(1)
        self.upload_file(LPL.upload_pictures, general_path, "上传头像定位失败截图")
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def slogan_error1(self):
        sleep(1)
        self.input(LPL.slogan, character_31, '口号输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def slogan_error2(self):
        sleep(1)
        self.input(LPL.slogan, character_30, '口号输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def slogan_success1(self):
        sleep(1)
        self.input(LPL.slogan, character_29, '口号输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def slogan_success2(self):
        sleep(1)
        self.input(LPL.slogan, '', '口号输入框定位输入失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def target_error1(self):
        sleep(1)
        self.input(LPL.target, character_31, '目标输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def target_error2(self):
        sleep(1)
        self.input(LPL.target, character_30, '目标输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def target_success1(self):
        sleep(1)
        self.input(LPL.target, character_29, '目标输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def target_success2(self):
        sleep(1)
        self.input(LPL.target, '', '目标输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def introduction_error1(self):
        sleep(1)
        self.input(LPL.introduction, character_1001, '简介输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def introduction_error2(self):
        sleep(1)
        self.input(LPL.introduction, character_1000, '简介输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def introduction_success1(self):
        sleep(1)
        self.input(LPL.introduction, character_999, '简介输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def introduction_success2(self):
        sleep(1)
        self.input(LPL.introduction, character_500, '简介输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def introduction_success3(self):
        sleep(1)
        self.input(LPL.introduction, '', '简介输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def note_error1(self):
        sleep(1)
        self.input(LPL.note, character_201, '备注输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def note_error2(self):
        sleep(1)
        self.input(LPL.note, character_200, '备注输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def note_success1(self):
        sleep(1)
        self.input(LPL.note, character_199, '备注输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def note_success2(self):
        sleep(1)
        self.input(LPL.note, '', '备注输入框定位失败截图')
        sleep(1)
        self.click(LPL.save, '保存按钮定位失败截图')

    def clear_all_inputbox(self):
        self.upload_file(LPL.upload_pictures, facepic_2MB, "上传头像")
        sleep(1)
        self.input(LPL.slogan, ' ', "口号输入框定位")
        self.input(LPL.target, ' ', "目标输入框定位")
        self.input(LPL.introduction, ' ', "简介输入框定位")
        self.input(LPL.note, ' ', "备注输入框定位")
        sleep(2)
        self.click(LPL.save, "保存按钮定位")













